home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 June: Reference Library / Dev.CD Jun 95 / Dev.CD Jun 95.toast / What's New? / New System Software Extensions / QuickDraw 3D ß / Programming / SampleCode / Modeller ƒ / modeller_podium.c < prev    next >
Encoding:
Text File  |  1995-03-31  |  19.0 KB  |  690 lines  |  [TEXT/MPS ]

  1. // modeller_podium.c -- this contains the podium specific routines for the modeller app
  2. //
  3. //
  4.  
  5.  
  6. #ifdef PODIUM_APP
  7.  
  8. #include "QD3D.h"
  9.  
  10. #include <Drag.h>
  11. #include <Events.h>
  12. #include <Controls.h>
  13. #include <ToolUtils.h>
  14. #include <Windows.h>
  15.  
  16. #include "QD3DView.h"
  17. #include "QD3DDrawContext.h"
  18. #include "QD3DDrawContext.h"
  19. #include "QD3DPick.h"
  20. #include "QD3DGroup.h"
  21. #include "QD3DTransform.h"
  22. #include "QD3DLight.h"
  23. #include "QD3DMath.h"
  24.  
  25.  
  26. #include <QuickDraw.h>
  27. #include <QDOffscreen.h>
  28.  
  29.  
  30. #include "Modeller_Document.h"
  31. #include "Modeller_Camera.h"
  32. #include "modeller_podium.h"
  33. #include "modeller_offscreen.h"
  34. #include "modeller_drag.h"
  35.  
  36.  
  37. static CursHandle        objectCursor, zoomInCursor, zoomOutCursor, handCursor;
  38.  
  39.  
  40. static TQ3Object DoHitTest(DocumentPtr    theDocument);
  41. static short PointInRect(Point *point, Rect *rect);
  42. static void Podium_UpdateDrawContextFromDropRect( DocumentPtr theDocument ) ;
  43.  
  44. //------------------------------------------------------------------------------------
  45. void Podium_UpdateDrawContextFromDropRect( DocumentPtr theDocument )
  46. {
  47.  
  48.     Rect                    frameRect ;
  49.     PixMapHandle            hPixMap ;
  50.     Rect                    srcRect ;
  51.     TQ3PixmapDrawContextData    myDrawContextData ;
  52.     
  53.     frameRect = theDocument->dropArea ;
  54.      
  55.     // if the drop area for the doc is the same as the GWorld's rect
  56.     // then we don't need to do anything, if they have changes we need
  57.     // to update the drawcontext
  58.     
  59.     if(!EqualRect(&frameRect,&theDocument->geometriesOffscreen->portRect)) {
  60.         TQ3DrawContextObject    theDrawContext ;
  61.         OSErr                theErr ;
  62.         
  63.         if((theErr = UpdateGWorld( &theDocument->geometriesOffscreen, 32, &frameRect, nil, nil, 0L )) == noErr
  64.             && (theErr = UpdateGWorld( &theDocument->maskOffscreen, 1, &frameRect, nil, nil, 0L )) == noErr) {    
  65.                         
  66.             theDrawContext = ModellerDocument_NewPixmapDrawContext( theDocument ) ;
  67.             Q3View_SetDrawContext(theDocument->theView, theDrawContext);
  68.             Q3Object_Dispose(theDrawContext);
  69.             
  70.             AdjustCamera(theDocument,
  71.                 theDocument->geometriesOffscreen->portRect.right - theDocument->geometriesOffscreen->portRect.left,
  72.                 theDocument->geometriesOffscreen->portRect.bottom - theDocument->geometriesOffscreen->portRect.top);
  73.         }
  74.     }
  75. }
  76.  
  77.         
  78.  
  79.  
  80.  
  81. static void MouseMoved(
  82.     DocumentPtr    theDocument,
  83.     long    oldX, 
  84.     long    oldY,
  85.     long    newX, 
  86.     long    newY)
  87. {
  88.     float                scaleFactor = 256.0;
  89.     unsigned long        winWidth, winHeight;
  90.     TQ3Matrix4x4            currentMatrix, tmp, newMatrix;
  91.     TQ3BoundingBox         viewBBox;
  92.     TQ3Point3D            modelCenter;
  93.     
  94.     /*
  95.      *  Find the bounding box for the group.
  96.      *  We'll use the center of the box as the point about which to rotate
  97.      *  (the old method always rotated about the world-space origin).
  98.      */
  99.  
  100.     /*
  101.      *  Get the width and height of the *current* window.
  102.      *  This is done so that mouse motion in a window has an effect
  103.      *  relative to the size of the window. 
  104.      */
  105.     winWidth  = theDocument->theWindow->portRect.right - theDocument->theWindow->portRect.left;
  106.     winHeight = theDocument->theWindow->portRect.bottom - theDocument->theWindow->portRect.top;
  107.  
  108.     GetGroupBBox(theDocument->theView, theDocument->documentGroup, NULL, &viewBBox);
  109.     
  110.     /*
  111.      *  The "to" point is the center of the view bounding box
  112.      */
  113.     {
  114.         float        weights[2] = { 0.5, 0.5 };
  115.         TQ3Point3D    points[2];
  116.         
  117.         points[0] = viewBBox.min;
  118.         points[1] = viewBBox.max;
  119.         
  120.         Q3Point3D_AffineComb(points, weights, 2, &modelCenter);
  121.     }
  122.             
  123.     /*
  124.      *  Make a new rotation matrix, rotating about the center of the view
  125.      *  bbox.
  126.      */            
  127.     {
  128.         float    xRot, yRot, zRot;
  129.         
  130.         xRot = yRot = zRot = 0.0;
  131.         
  132.         xRot = Q3Math_DegreesToRadians((float)(newY - oldY) / winHeight * scaleFactor);
  133.         yRot = Q3Math_DegreesToRadians((float)(newX - oldX) / winWidth * scaleFactor);
  134.  
  135.         if ((xRot != 0.0) || (yRot != 0.0)){
  136.             Q3Matrix4x4_SetRotateAboutPoint(&tmp, &modelCenter, xRot, yRot, zRot);
  137.             Q3Matrix4x4_Multiply(&theDocument->modelRotation, &tmp, &theDocument->modelRotation);
  138.         }
  139.     }
  140.  
  141. }
  142.  
  143.  
  144. static short PointInRect(Point *point, Rect *rect)
  145. {
  146.     if( point->h > rect->left && point->h < rect->right ) {
  147.         if( point->v > rect->top && point->v < rect->bottom ) {
  148.             return(1);
  149.         } else {
  150.             return(0);
  151.         }
  152.     } else {
  153.         return(0);
  154.     }
  155. }
  156.  
  157.  
  158. static Boolean PtOnHandles(Point *newMouse, Rect *location, short *whichHandle)
  159. {
  160.     Rect    handlesRect;
  161.     
  162.     handlesRect.left = location->left - 4;
  163.     handlesRect.top = location->top - 4;
  164.     handlesRect.right = location->left;
  165.     handlesRect.bottom = location->top;
  166.     
  167.     if( PointInRect(newMouse, &handlesRect) ) {
  168.         *whichHandle = LeftTopHandle;
  169.         return(true);
  170.     }
  171.     
  172.     handlesRect.left = location->right;
  173.     handlesRect.right = location->right + 4;
  174.     
  175.     if( PointInRect(newMouse, &handlesRect) ) {
  176.         *whichHandle = RightTopHandle;
  177.         return(true);
  178.     }
  179.     
  180.     handlesRect.left = location->right;
  181.     handlesRect.right = location->right + 4;
  182.     handlesRect.top = location->bottom;
  183.     handlesRect.bottom = location->bottom + 4;
  184.     
  185.     if( PointInRect(newMouse, &handlesRect) ) {
  186.         *whichHandle = RightBottomHandle;
  187.         return(true);
  188.     }
  189.     
  190.     handlesRect.left = location->left - 4;
  191.     handlesRect.right = location->left;
  192.     
  193.     if( PointInRect(newMouse, &handlesRect) ) {
  194.         *whichHandle = LeftBottomHandle;
  195.         return(true);
  196.     }
  197.     return(false);
  198. }
  199.  
  200. static void DrawHandles(Rect *location)
  201. {
  202.     Rect    handlesRect;
  203.     
  204.     handlesRect.left = location->left - 4;
  205.     handlesRect.top = location->top - 4;
  206.     handlesRect.right = location->left;
  207.     handlesRect.bottom = location->top;
  208.     
  209.     PaintRect(&handlesRect);
  210.     
  211.     handlesRect.left = location->right;
  212.     handlesRect.right = location->right + 4;
  213.     
  214.     PaintRect(&handlesRect);
  215.     
  216.     handlesRect.left = location->right;
  217.     handlesRect.right = location->right + 4;
  218.     handlesRect.top = location->bottom;
  219.     handlesRect.bottom = location->bottom + 4;
  220.     
  221.     PaintRect(&handlesRect);
  222.     
  223.     handlesRect.left = location->left - 4;
  224.     handlesRect.right = location->left;
  225.     
  226.     PaintRect(&handlesRect);
  227.     
  228.     PenSize(2,2);
  229.     MoveTo(location->left - 2, location->top - 2);
  230.     LineTo(location->right, location->top - 2);
  231.     LineTo(location->right, location->bottom);
  232.     LineTo(location->left - 2, location->bottom);
  233.     LineTo(location->left - 2, location->top - 2);
  234.     //FrameRect(location);
  235. }
  236.  
  237. /*
  238.  *    hit test a click in the document.
  239.  */
  240.  
  241. static TQ3Object DoHitTest(DocumentPtr    theDocument)
  242. {
  243.     TQ3WindowPointPickData    withData;
  244.     unsigned long        numPicked;
  245.     TQ3RendererObject    saveRenderer;
  246.     TQ3PickObject        pickObject;
  247.     TQ3DrawContextObject    drawCtx;
  248.     
  249.     withData.data.sort             =    kQ3PickSortNone;
  250.     withData.data.numHitsToReturn=    1;
  251.     withData.data.mask             =    kQ3PickDetailMaskObject;
  252.                                   
  253.     withData.point.x = theDocument->mouseLocation.h - theDocument->dropArea.left;
  254.     withData.point.y = theDocument->mouseLocation.v - theDocument->dropArea.top;
  255.  
  256.     withData.vertexTolerance = withData.edgeTolerance = 3;
  257. // this field gone in beta:    withData.view = theDocument->theView;
  258.  
  259.     pickObject = Q3WindowPointPick_New(&withData);
  260.  
  261.     Q3View_GetRenderer(theDocument->theView, &saveRenderer);
  262.     Q3View_GetDrawContext(theDocument->theView, &drawCtx);
  263.  
  264.     Q3View_SetRendererByType(theDocument->theView, kQ3RendererTypeGeneric);
  265.     Q3Object_Dispose(drawCtx);
  266.     
  267.     Q3View_StartRendering(theDocument->theView );
  268.     do {
  269.         Q3DisplayGroup_Submit(theDocument->documentGroup, theDocument->theView);
  270.     } while (Q3View_EndRendering(theDocument->theView) == kQ3ViewStatusRetraverse);
  271.     
  272.     Q3View_SetRenderer(theDocument->theView, saveRenderer);
  273.  
  274.     Q3Object_Dispose(saveRenderer);
  275.     
  276.     if (Q3Pick_GetNumHits(pickObject, &numPicked) && (numPicked != 0)) {
  277.         TQ3HitData hitData;
  278.         
  279.         // used to be: ErPick_GetFirstHit(pickObject, &hitData);
  280.         Q3Pick_GetHitData( pickObject, 1, &hitData );
  281.         Q3Object_Dispose(pickObject);
  282.         return(hitData.object);
  283.     } else {
  284.         Q3Object_Dispose(pickObject);
  285.         return(NULL);
  286.     }
  287.     
  288. }
  289.  
  290. /*
  291.  *    DoContent handles mouseDown events in the content region of a document window.
  292.  *
  293.  *    (1)    If the mouseDown is on a control, handle the click by calling TrackControl.
  294.  *
  295.  *    (2)    If the mouseDown is on a draggable object (the document's hiliteRgn) and a
  296.  *        successful drag occurs, no further processing is necessary.
  297.  *
  298.  *    (3)    If the mouseDown is on a draggable object and the mouse is released without
  299.  *        dragging, set the insertion point to the original mouseDown location by calling
  300.  *        TEClick with the mouseDown information.
  301.  *
  302.  *    (4)    If the mouseDown is not on a draggable object and within the viewRect of the
  303.  *        TextEdit field, call TEClick to handle the mouseDown.
  304.  */
  305.  
  306. void Podium_DoContent(DocumentPtr    theDocument, EventRecord *theEvent)
  307.  
  308. {    short            thePart;
  309.     Point            thePoint;
  310.     ControlHandle    theControl;
  311.  
  312.     SetPort(theDocument->theWindow);
  313.     thePoint = theEvent->where;
  314.  
  315.     if( theDocument->documentGroup ) {
  316.         Point     newMouse, offset;
  317.         short    whichHandle;
  318.         
  319.         GetMouse(&newMouse);
  320.         theDocument->mouseLocation = newMouse;
  321.         
  322.         /* First check for resize */
  323.         if( theDocument->currentlySelectedObject && PtOnHandles(&newMouse, &theDocument->dropArea, &whichHandle) ) {
  324.                 Rect    previousRect;
  325.                 Rect    frameRect;
  326.                 Point     oldMouse;
  327.                 TQ3Boolean    needRedraw;
  328.                 
  329.                 PenMode(srcXor);
  330.                 PenSize(2,2);
  331.                 frameRect = previousRect = theDocument->dropArea;
  332.                 
  333.                 oldMouse = theDocument->mouseLocation;
  334.                 switch( whichHandle ){
  335.                     case LeftTopHandle:
  336.                         
  337.                         offset.h = newMouse.h - frameRect.left;
  338.                         offset.v = newMouse.v - frameRect.top;
  339.  
  340.                         while (WaitMouseUp()) {
  341.                             GetMouse(&newMouse);
  342.                             if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  343.                                 newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  344.                                     needRedraw = kQ3True;
  345.                                     frameRect.left = newMouse.h - offset.h;
  346.                                     frameRect.top = newMouse.v - offset.v;
  347.                                     DrawHandles(&previousRect);
  348.                                     DrawHandles(&frameRect);
  349.                                     previousRect = frameRect;
  350.                             }
  351.                         }
  352.                     break;
  353.                     case RightTopHandle:
  354.                         
  355.                         offset.h = newMouse.h - frameRect.right;
  356.                         offset.v = newMouse.v - frameRect.top;
  357.  
  358.                         while (WaitMouseUp()) {
  359.                             GetMouse(&newMouse);
  360.                             if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  361.                                 newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  362.                                     needRedraw = kQ3True;
  363.                                     frameRect.right = newMouse.h - offset.h;
  364.                                     frameRect.top = newMouse.v - offset.v;
  365.                                     DrawHandles(&previousRect);
  366.                                     DrawHandles(&frameRect);
  367.                                     previousRect = frameRect;
  368.                             }
  369.                         }
  370.                     break;
  371.                     case LeftBottomHandle:
  372.                         
  373.                         offset.h = newMouse.h - frameRect.left;
  374.                         offset.v = newMouse.v - frameRect.bottom;
  375.  
  376.                         while (WaitMouseUp()) {
  377.                             GetMouse(&newMouse);
  378.                             if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  379.                                 newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  380.                                     needRedraw = kQ3True;
  381.                                     frameRect.left = newMouse.h - offset.h;
  382.                                     frameRect.bottom = newMouse.v - offset.v;
  383.                                     DrawHandles(&previousRect);
  384.                                     DrawHandles(&frameRect);
  385.                                     previousRect = frameRect;
  386.                             }
  387.                         }
  388.                     break;
  389.                     case RightBottomHandle:
  390.                         
  391.                         offset.h = newMouse.h - frameRect.right;
  392.                         offset.v = newMouse.v - frameRect.bottom;
  393.  
  394.                         while (WaitMouseUp()) {
  395.                             GetMouse(&newMouse);
  396.                             if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  397.                                 newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  398.                                     needRedraw = kQ3True;
  399.                                     frameRect.right = newMouse.h - offset.h;
  400.                                     frameRect.bottom = newMouse.v - offset.v;
  401.                                     DrawHandles(&previousRect);
  402.                                     DrawHandles(&frameRect);
  403.                                     previousRect = frameRect;
  404.                             }
  405.                         }
  406.                     break;
  407.                 }
  408.     
  409.                 theDocument->dropArea = frameRect;
  410.                 
  411.                 if( needRedraw == kQ3True ) {
  412.                     Podium_UpdateDrawContextFromDropRect( theDocument ) ;
  413.                     DrawOffscreen(theDocument);
  414.                     DrawOnscreen(theDocument);
  415.                     
  416.                 }
  417.                         
  418.                 PenMode(srcXor);
  419.                 PenSize(2,2);
  420.                 PenPat(&qd.black);
  421.                 DrawHandles(&frameRect);
  422.         /* is it in content */
  423.         } else if( PtInRect(newMouse, &theDocument->dropArea) ) {
  424. //            TQ3Object    newPick;
  425. //        if(( newPick = DoHitTest(theDocument)) != NULL) {
  426.             if( theDocument->selected == kQ3False) {
  427.                 PenMode(srcXor);
  428.                 PenSize(2,2);
  429.                 PenPat(&qd.black);
  430.                 DrawHandles(&theDocument->dropArea);
  431.             }
  432.             
  433.             theDocument->currentlySelectedObject = theDocument->documentGroup ;
  434.             
  435.             if( theEvent->modifiers & shiftKey )
  436.                 SetCursor(*zoomInCursor);
  437.             else if( theEvent->modifiers & cmdKey )
  438.                 SetCursor(*zoomOutCursor);
  439.             else
  440.                 SetCursor(*objectCursor);
  441.         
  442.             if( theEvent->modifiers & shiftKey ) {
  443.                 TQ3Matrix4x4    tmp;
  444.                 
  445.                 Q3Matrix4x4_SetScale(&tmp, 1.2, 1.2, 1.2);
  446.                 while (WaitMouseUp()) {
  447.                     Q3Matrix4x4_Multiply(&tmp, &theDocument->modelRotation, &theDocument->modelRotation);
  448.                     DrawOffscreen( theDocument ) ;
  449.                     DrawOnscreen( theDocument ) ;
  450.                 }
  451.             } else if( theEvent->modifiers & cmdKey ) {
  452.                 TQ3Matrix4x4    tmp;
  453.                 
  454.                 Q3Matrix4x4_SetScale(&tmp, 0.83333, 0.83333, 0.83333);
  455.                 while (WaitMouseUp()) {
  456.                     Q3Matrix4x4_Multiply(&tmp, &theDocument->modelRotation, &theDocument->modelRotation);
  457.                     DrawOffscreen(theDocument);
  458.                     DrawOnscreen( theDocument ) ;
  459.                 }
  460.             } else if( theEvent->modifiers & controlKey ) {
  461.             
  462.                 Point     oldMouse;
  463.                 Point     newMouse;
  464.                 long     mouseChanged = 0;
  465.                 long    dx, dy, x, y, oldX, oldY;
  466.                 float    width, height;
  467.                 float    xRot, yRot;
  468.                         
  469.                 SetCursor(*handCursor);
  470.                 GetMouse(&newMouse);        // get the mouse in local co-ordinates, 
  471.                                                 // local to the  current GrafPort
  472.         
  473.                 oldX = newMouse.h;
  474.                 oldY = newMouse.v;
  475.                 
  476.                 width = theDocument->geometriesOffscreen->portRect.right - theDocument->geometriesOffscreen->portRect.left;
  477.                 height =  theDocument->geometriesOffscreen->portRect.bottom - theDocument->geometriesOffscreen->portRect.top;
  478.     
  479.                 while (WaitMouseUp()) {
  480.                 
  481.                     GetMouse(&newMouse);        // get the mouse in local co-ordinates, 
  482.                                                 // local to the  current GrafPort
  483.     
  484.                     dx = newMouse.v - oldY;
  485.                     dy = newMouse.h - oldX;
  486.                     
  487.                     if ((dx != 0) || (dy != 0)) {
  488.                         TQ3Matrix4x4        tempMatrix;
  489.                         
  490.                         xRot = ((float) dx * kQ3Pi) / width;
  491.                         yRot = ((float) dy * kQ3Pi) / height;
  492.             
  493.                         if ((xRot != 0.0) || (yRot != 0.0)) {
  494.                             Q3Matrix4x4_SetRotate_XYZ(&tempMatrix, xRot, yRot, 0.0);
  495.                             Q3Matrix4x4_Multiply(&theDocument->modelRotation, &tempMatrix, &theDocument->modelRotation);
  496.     
  497.                             mouseChanged = 1;
  498.                             DrawOffscreen(theDocument);
  499.                             DrawOnscreen( theDocument ) ;
  500.                         }
  501.                     }
  502.                     oldX = newMouse.h; oldY = newMouse.v;
  503.                 }
  504.                 
  505.                 if( mouseChanged ) {
  506.                     theDocument->rotationDir.x = xRot;
  507.                     theDocument->rotationDir.y = yRot;
  508.                 }
  509.             } else {
  510.                 Rect    previousRect;
  511.                 Rect    frameRect;
  512.                 Point     oldMouse;
  513.                 TQ3Boolean    needRedraw;
  514.                 long    height, width;
  515.                 
  516.                 PenMode(srcXor);
  517.                 PenSize(2,2);
  518.                 frameRect = previousRect = theDocument->dropArea;
  519.                 height = frameRect.bottom - frameRect.top;
  520.                 width = frameRect.right - frameRect.left;
  521.                 
  522.                 offset.h = newMouse.h - frameRect.left;
  523.                 offset.v = newMouse.v - frameRect.top;
  524.                 
  525.                 oldMouse = theDocument->mouseLocation;
  526.                 while (WaitMouseUp()) {
  527.                     GetMouse(&newMouse);
  528.                     if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  529.                         newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  530.                             needRedraw = kQ3True;
  531.                             frameRect.left = newMouse.h - offset.h;
  532.                             frameRect.top = newMouse.v - offset.v;
  533.                             frameRect.right = frameRect.left + width;
  534.                             frameRect.bottom = frameRect.top + height;
  535.                             DrawHandles(&previousRect);
  536.                             DrawHandles(&frameRect);
  537.                             previousRect = frameRect;
  538.                     }
  539.                 }
  540.     
  541.                 theDocument->dropArea = frameRect;
  542.                 
  543.                 if( needRedraw == kQ3True ) {
  544.                     Podium_UpdateDrawContextFromDropRect( theDocument ) ;
  545.                     DrawOffscreen(theDocument);
  546.                     DrawOnscreen(theDocument);
  547.                         
  548.                 }
  549.                 PenMode(srcXor);
  550.                 PenSize(2,2);
  551.                 PenPat(&qd.black);
  552.                 DrawHandles(&frameRect);
  553.             }
  554.         } else {
  555.             if( theDocument->selected == kQ3True) {
  556.                 theDocument->currentlySelectedObject = NULL;
  557.                 theDocument->selected = kQ3False;
  558.                 PenMode(srcXor);
  559.                 PenSize(2,2);
  560.                 PenPat(&qd.black);
  561.                 DrawHandles(&theDocument->dropArea);
  562.             }
  563.             SetCursor(&qd.arrow);
  564.         }
  565.     } 
  566.     else  {
  567.     
  568.         if( theDocument->currentlySelectedObject ) {
  569.             theDocument->currentlySelectedObject = NULL;
  570.             PenMode(srcXor);
  571.             PenSize(2,2);
  572.             DrawHandles(&theDocument->dropArea);
  573.             SetCursor(&qd.arrow);
  574.         }
  575.     }
  576. }
  577.  
  578.  
  579. /*
  580.  *    DoBackgroundContent handles mouseDown events in the content region of a document window
  581.  *    when the window is not frontmost. The following bullet items describe how this background
  582.  *    mouseDown event is handled:
  583.  *
  584.  *    (1)    If the mouseDown is not in a draggable object (not in the document's hiliteRgn) call
  585.  *        SelectWindow to bring the window to the front as usual.
  586.  *
  587.  *    (2)    If the mouseDown is in a draggable object and the mouse is released without
  588.  *        dragging, call SelectWindow when the mouse is released.
  589.  *
  590.  *    (3)    If the mouseDown is in a draggable object and a successful drag occurs, SelectWindow
  591.  *        should only be called if the drop occurred in the same window (the DragText function
  592.  *        calls SelectWindow in this case).
  593.  */
  594.  void Podium_DoBackgroundContent(DocumentPtr    theDocument, EventRecord *theEvent)
  595.  
  596. {    short            thePart;
  597.     Point            thePoint;
  598.     ControlHandle    theControl;
  599.     RgnHandle        tempRgn = NewRgn();  // Nick this needs to be the BBox of the group
  600.  
  601.     SetPort(theDocument->theWindow);
  602.     thePoint = theEvent->where;
  603.     GlobalToLocal(&thePoint);
  604.  
  605.     RectRgn(tempRgn, &theDocument->geometriesOffscreen->portRect);
  606.  
  607.     if (PtInRgn(thePoint,tempRgn)) {
  608.         if (! DoDragObjects(theDocument, theEvent, tempRgn)) {
  609.             SelectWindow(theDocument->theWindow);
  610.         }
  611.     } 
  612.     else {
  613.         SelectWindow(theDocument->theWindow);
  614.     }
  615.     
  616.     DisposeRgn(tempRgn);
  617. }
  618.  
  619.  
  620.  
  621.  
  622. /*
  623.  *    DoIdle get called repetitively while the application is not doing
  624.  *    anything.
  625.  */
  626.  
  627. void Podium_DoIdle(EventRecord *theEvent)
  628. {
  629.     WindowPtr        theWindow;
  630.     DocumentPtr    theDocument;
  631.  
  632.     if ((theWindow = FrontWindow()) != nil) {
  633.         if ((theDocument = GetDocumentFromWindow(theWindow)) != nil) {
  634.             SetPort(theDocument->theWindow);
  635.  
  636.             if( theDocument->documentGroup ) {
  637.                 Point     mouseLocation;
  638.                 
  639.                 GetMouse(&mouseLocation);
  640.  
  641.                  theDocument->mouseLocation = mouseLocation;
  642.                  
  643.                  if( PointInRect(&theDocument->mouseLocation, &theDocument->dropArea) ) {
  644.                     if(DoHitTest(theDocument)) {
  645.                         if( theEvent->modifiers & shiftKey) {
  646.                             SetCursor(*zoomInCursor);
  647.                         } else if( theEvent->modifiers & cmdKey) {
  648.                             SetCursor(*zoomOutCursor);
  649.                         } else if( theEvent->modifiers & controlKey) {
  650.                             SetCursor(*handCursor);
  651.                         } else {
  652.                             SetCursor(*objectCursor);
  653.                         }
  654.                     } else {
  655.                         SetCursor(&qd.arrow);
  656.                     }
  657.                 } else {
  658.                     SetCursor(&qd.arrow);
  659.                 }
  660.                 
  661.                 if( theDocument->animateModel == kQ3True) {
  662.                     TQ3Matrix4x4    tmp;
  663.                     
  664.                     if( theDocument->rotationDir.x == 0.0 && theDocument->rotationDir.y == 0.0 ) {
  665.                         Q3Matrix4x4_SetRotate_XYZ(&tmp, 0.03, 0.08, 0.0);
  666.                         Q3Matrix4x4_Multiply(&theDocument->modelRotation, &tmp, &theDocument->modelRotation);
  667.                     } else {
  668.                         Q3Matrix4x4_SetRotate_XYZ(&tmp, theDocument->rotationDir.x, theDocument->rotationDir.y, 0.0);
  669.                         Q3Matrix4x4_Multiply(&theDocument->modelRotation, &tmp, &theDocument->modelRotation);
  670.                     }
  671.                     DrawOffscreen(theDocument);
  672.                     DrawOnscreen(theDocument);
  673.                 }
  674.             }
  675.         }
  676.     }
  677. }
  678.  
  679. void Podium_Init(void)
  680. {
  681.     objectCursor = GetCursor(132);
  682.     zoomInCursor = GetCursor(133);
  683.     zoomOutCursor = GetCursor(134);
  684.     handCursor = GetCursor(130);
  685. }
  686.  
  687.  
  688.  
  689. #endif PODIUM_APP
  690.